<!DOCTYPE html>
<html>

<head>
    <title>编辑用户</title>
    <my_css>
        <link rel="stylesheet" href="/assets/css/select2.min.css" />
    </my_css>
</head>

<body>

<div class="page-header">
    <h1>${_resource_name!''}
        <small><i class="ace-icon fa fa-angle-double-right"></i>
            编辑用户
        </small>
    </h1>
</div><!-- /.page-header -->

<div class="row">
    <div class="col-xs-12">
        <!-- PAGE CONTENT BEGINS -->
        <input type="file" name="uploadFile" id="upFileId" onchange="uploadPortrait()" style="display: none;"/>

        <form id="common_form" class="form-horizontal" role="form" action="${ctlKey}/update" method="post">
            <div class="col-xs-12 col-sm-3 center">
                <div>
				<span class="profile-picture">
					<img id="portraitImg" class="editable img-responsive editable-click" src="<#if user.portraitShowUri??>${user.portraitShowUri!}<#else>/assets/images/avatars/user.jpg</#if>" width="180" height="200"/>
				</span>
                    <div class="space-4"></div>
                </div>
                <input id="portraitShowUri" name="portraitShowUri" type="hidden" value="${user.portraitShowUri!}"/>
                <input id="portraitFileId" name="portraitFileId" type="hidden" value="${user.portraitFileId!}"/>
                <div class="space-6"></div>
            </div>
            <input name="userId" type="hidden" value="${user.id!}"/>
            <div class="col-xs-12 col-sm-9">
                <@form_input l="账号" val=user.userNm name="userNm"  readonly=true/>
                <@form_input l="姓名" name="userRealNm" val=user.userRealNm p="Realname" r=true/>
                <@form_input l="电话" name="mobileNo" val=(user.mobileNo)! p="Mobile"/>
                <@form_input l="邮箱" name="email" val=(user.email)! p="Email"/>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 角色 </label>
                    <div class="col-sm-9">
                        <div class="clearfix">
                            <select multiple="" name="roleIdList" class="select2 tag-input-style" data-placeholder="Click to Choose..." autocomplete="off" required>
                                <#list roleList as role>
                                    <option value="${role.id}"  <#if roleIdList?seq_contains(role.id)>selected</#if>>${role.roleName}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit">
                            <i class="ace-icon fa fa-check bigger-110"></i> Submit
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="ace-icon fa fa-undo bigger-110"></i> Reset
                        </button>
                    </div>
                </div>

            </div>

        </form>
        <!-- PAGE CONTENT ENDS -->
    </div><!-- /.col -->
</div><!-- /.row -->

</body>
<my_script>
    <script src="/assets/js/jquery.validate.min.js"></script>
    <script src="/common/js/jquery.validate.default.js"></script>
    <script src="/common/js/common.form.js"></script>
    <script src="/common/js/common.js"></script>
    <script src="/common/js/ajaxfileupload.js"></script>
    <script src="/common/js/bootbox.js"></script>
    <script src="/assets/js/select2.min.js"></script>


    <script type="text/javascript">
        $('.select2').css('width','200px').select2({allowClear:true});
        jQuery(function($) {
            $("#portraitImg").click(function(){
                $("#upFileId").click();
            });
            $('.select2').addClass('tag-input-style');
        });
        function uploadPortrait() {
            uploadLocalFile("portrait");
        }

        function afterUpload(data) {
            if (data.data && data.data != null && data.data != "") {
                $("#portraitImg").attr("src", data.data.fileShowUri);
                $("#portraitShowUri").val(data.data.fileShowUri);
                $("#portraitFileId").val(data.data.id);
            }
        }

        function submitHandler(){
            ctlKey = "/admin/user/edit/${user.id!}";
            return true;
        }
    </script>

</my_script>

</html>